/**
 * Created by GYL on 2018/7/25
 */
import React, { Component } from 'react';
import {   Collapse } from 'antd';
import MyTable from '../../../components/common/MyTable';
import Container from '../../../components/common/Container';
import PublicService from '../../../services/PublicService';
import request from '../../../utils/request';
import moment from 'moment';
var dataSource1 = [

]
class BlabDay extends Component {
    constructor(props) {
        super(props)
        this.columns = [
            {
                title: '企业',
                dataIndex: 'company',
                width: '10%',
                align: "center",
                key:"1",
               
            },
           
            {
                title: '站点名称',
                dataIndex: 'gasStationName',
                width: '15%',
                align: "center",
                key:"2",
               
            },
            {
                title: '甲烷实时值(mg/m³)',
                dataIndex: 'ch4',
                width: '10%',
                align: "center",
                key:"3",
                render: (text,record) => <span style={{cursor:"pointer"}} onClick={this.onCurrent.bind(this,record)}>{text}</span>
                    
                
            },
            {
                title: '甲烷小时均值(mg/m³)',
                width: '10%',
                dataIndex: 'avg',
                align: "center",
                key:"4",
                render: (text,record) => <span style={{cursor:"pointer"}} onClick={this.onHour.bind(this,record)}>{text}</span>
            },
            {
                title: '标准值(mg/m³)',
                dataIndex: 'criticalValue',
                width: '10%',
                align: "center",
                key:"5",
               
            },
            {
                title: '当日报警次数(个)',
                dataIndex: 'alarmNum',
                width: '10%',
                align: "center",
                key:"6",
               
            }
        ];

    }

    state = {
        loading: false,
        selectedRowKeys: [],
        selectedRows: [],
        dataSource: [],
        pageIndex: 1,
        pageSize: 10,
    }

    componentDidMount() {

        request({
            url: '/zhrq-web/gas/gasMonitor/getRunTimeDate',
            method: 'GET',
        }).then(data => {
            console.log(data)
            if(data.rc === 0) {
                this.setState({
                    dataSource:data.ret
                })
            }
        })

    }
    onCurrent = (record) => {
        console.log(record)
        PublicService.setCookie('gasStationName', record.gasStationName);
       

        this.props.history.push('/BlabCurrent');
    }

    onHour = (record) => {
        console.log(record)
        PublicService.setCookie('gasStationName', record.gasStationName);
        this.props.history.push('/BlabHour');

    }

    render() {
        const { loading, selectedRowKeys, dataSource, pageIndex, pageSize } = this.state
        const columns = this.columns
        const windowWidth = document.body.clientWidth;

        const height = document.body.clientHeight;
        let containerHeight = '86vh';
        if (windowWidth > 1367) {
            containerHeight = '86vh';
        }

        return (
            <div>
                <Container
                    style={{ height: containerHeight, position: "relative", marginTop: "1vh" }}
                    header={true}
                >

                    <MyTable
                        // bordered
                        loading={loading}
                        columns={columns}
                        // rowSelection={rowSelection}
                        pagination={false}
                        // scroll={{ y: windowWidth < 1400 ? height - 280 : height - 300 }}
                        dataSource={PublicService.transformArrayData(dataSource, true, true, pageIndex, pageSize)}
                    />
                </Container>
            </div>
        )
    }
}
export default (BlabDay);
